set(priv_requires
    nvs_flash
    esp_netif
    spiffs
    network_manager
    esp_driver_gpio
    esp_http_server
    fatfs
    json
    esp_driver_uart
)

idf_component_register(SRCS "esp_rest_main.c"
                            "rest_server.c"
                            "app_uart.c"
                            "tcp_server.c"
                    INCLUDE_DIRS "."
                    PRIV_REQUIRES "${priv_requires}")


if(CONFIG_EXAMPLE_WEB_DEPLOY_SF)
    set(WEB_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../www")
    if(EXISTS ${WEB_SRC_DIR}/dashboard)
        spiffs_create_partition_image(www ${WEB_SRC_DIR}/dashboard FLASH_IN_PROJECT)
    else()
        message(FATAL_ERROR "${WEB_SRC_DIR}/dist doesn't exit. Please run 'npm run build' in ${WEB_SRC_DIR}")
    endif()
endif()
